<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

use app\portal\controller\HomeBaseController;
use app\admin\model\ClienteleModel;


class ClienteleController extends HomeBaseController
{

    public function index()
    {
        $clienteleModel = new ClienteleModel();
        
        $list = $clienteleModel
                ->order('list_order')                      
                ->paginate(array(
                    'list_rows'=>16,
                    'next'=>'下一页',
                    'prev'=>'上一页'
                ));
        $page = $list->render();

        $assign_arr = array(
            'list' => $list->items(),
            'page' => $page
        );

        $category=db('nav_menu')->where('href','/clientele')->find();
        $this->assign('category', $category); 
        $this->assign($assign_arr);

        return $this->fetch('clientele');
    }



   public function clienteleDetail()
    {
        
        

        $articleId  = $this->request->param('id', 0, 'intval');
        $categoryId = $this->request->param('cid', 0, 'intval');

        $article = db('clientele')->where('id',$articleId)->find();
        $article['post_content']=cmf_replace_content_file_url(htmlspecialchars_decode($article['post_content']));

        $article['more'] = json_decode($article['more'],TRUE);
        $prev_article = db('clientele') -> where('id','<',$articleId) -> find();
        $next_article = db('clientele') -> where('id','>',$articleId) -> find();
        if ($prev_article == null) {
            $prev_article['id'] = $articleId;
            $prev_article['post_title'] = "没有了";
        }
        if ($next_article == null) {
            $next_article['id'] = $articleId;
            $next_article['post_title'] = "没有了";
        }
        $this ->assign('prev_article',$prev_article);
        $this ->assign('next_article',$next_article);
       

     
  

        $this->assign('article', $article);       
       
       
      
        return $this->fetch('clientele/clientele_detail');
    }
}